package com.gitee.wsl.struct.prioritizer


import com.gitee.wsl.collections.queue.ArrayQueue
import kotlin.Comparator

object PrioritizerExt{

    fun <T> defaultPrioritizer(comparator: Comparator<T> ? =null):Prioritizer<T> = DefaultPrioritizer(comparator)

    fun <T> insertionOrderPrioritizer():Prioritizer<T> = InsertionOrderPrioritizer()
}

fun interface Prioritizer<T> {
    fun newMappingCollection(): ArrayQueue<T>
}

abstract class BasePrioritizer<T>:Prioritizer<T>{}

class DefaultPrioritizer<T>(val comparator: Comparator<T>?=null) : BasePrioritizer<T>() {
    override fun newMappingCollection(): ArrayQueue<T> {
        return ArrayQueue(comparator)
    }
}

class InsertionOrderPrioritizer<T> : BasePrioritizer<T>() {
    override fun newMappingCollection(): ArrayQueue<T> {
        return ArrayQueue<T>()
    }
}